package cn.net.cfss.fgbp.provider.console.biz;

import cn.net.cfss.fgbp.api.console.dto.SysAppMenuDto;
import cn.net.cfss.fgbp.api.console.vo.SysAppMenuVo;
import cn.net.cfss.fgbp.base.common.biz.BaseBiz;
import cn.net.cfss.fgbp.provider.console.dao.SysAppMenuDtoMapper;
import cn.net.cfss.fgbp.provider.console.utils.FgbpIdUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author oygq
 * @title: AppMenuDtoBiz
 * @description: TODO
 * @date 2019/4/3 11:01
 */
@Service
public class SysAppMenuDtoBiz extends BaseBiz<SysAppMenuDtoMapper, SysAppMenuDto> {

    @Transactional
    public void deleteBatch(String[] appMenuIds){
        mapper.deleteBatch(appMenuIds);
    }

    @Transactional
    public void insertBatch(SysAppMenuVo vo){
        for(String menu : vo.getMenuIds()){
            SysAppMenuVo appMenu = new SysAppMenuVo();
            appMenu.setId(FgbpIdUtil.generateId());
            appMenu.setMenuId(Long.valueOf(menu));
            appMenu.setAppId(vo.getAppId());
            insert(appMenu);
        }
    }

    public void deleteByMenus(SysAppMenuVo vo){
        mapper.deleteByMenus(vo);
    }
}

